﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;
using YRevitJig;

namespace YArchitech.Plumbing
{
	public class SingleRiserPipeLinesJig : RiserPipeLinesJig
	{
		public SingleRiserPipeLinesJig(UIDocument uiDoc, FrmMarkRiserpipe form) : base(uiDoc, form)
		{
		}

		public override void Draw(PaintEventArgs paintEventArgs)
		{
			base.Draw(paintEventArgs);
			if (!this.m_ptCur.IsEmpty && paintEventArgs != null)
			{
				try
				{
					base.UpdateData();
					double textLength = UnifiedModified.GetTextLength(this.formData.checkAreaNumber.Checked, this.formData.checkFloorNumber.Checked);
					this.resultLines.Clear();
					XYZ xyz = base.Client2Revit(this.m_ptCur);
					XYZ xyz2 = new XYZ(xyz.X, xyz.Y, base.StartPoint.Z);
					XYZ xyz3 = null;
					XYZ xyz4 = null;
					if (xyz2.X < base.StartPoint.X)
					{
						this.isLeft = true;
					}
					else
					{
						this.isLeft = false;
					}
					if (!this.formData.checkDisToPipe.Checked)
					{
						base.Distance = AssistFunc.feetToMM(Math.Abs(xyz2.Y - base.StartPoint.Y));
					}
					this.resultLines = MarkRiserPipeUtility.DrawSinglePipeMarkLines(base.StartPoint, xyz2, base.Angle, base.IsUseCustomAngle, base.Distance, textLength, ref xyz3, ref xyz4, base.Doc, this.isLeft);
					XGraphics g = new XGraphics(paintEventArgs.Graphics, base.JigPen);
					foreach (Line curve in this.resultLines)
					{
						new XLine2D(base.Revit2Client(curve.GetEndPoint(0)), base.Revit2Client(curve.GetEndPoint(1))).Draw(g);
					}
				}
				catch (Exception ex)
				{
					ex.ToString();
				}
			}
		}

		public override List<Curve> CreateCurves()
		{
			List<Curve> list = new List<Curve>();
			foreach (Line item in this.resultLines)
			{
				list.Add(item);
			}
			return list;
		}

		public bool isLeft;
	}
}
